﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OF.Web
{
    public partial class shop : System.Web.UI.Page
    {
        BLL.Addr.AreaCache area_cache = new BLL.Addr.AreaCache();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string sellerid = Request.QueryString["id"];
                if (!string.IsNullOrWhiteSpace(sellerid))
                {
                    rptList.DataSource = area_cache.GetDishsBySellerId(Convert.ToInt32(sellerid));
                    rptList.DataBind();
                }
              
                string type = Common.RequestHelp.GetQueryString("type",true);

                string ordershop = "";
                string has_ordershop = Common.Cookie.getCookie("ordershop");    //已经存在的ordershop
                if (type == "waimai")
                {
                    ordershop = "waimai_" + sellerid;
                    Common.Cookie.addCookie("ordershop", ordershop);
                }
                else if (type == "diancan")
                {
                    ordershop = "diancan_" + sellerid;
                    Common.Cookie.addCookie("ordershop", ordershop);
                }
                else
                {
                    //没有选择点餐或是外卖
                    Response.Redirect("index.aspx");
                }
               
                string dishcart = Common.Cookie.getCookie("dishcart");
                if (!string.IsNullOrEmpty(has_ordershop) && !string.IsNullOrEmpty(dishcart) && ordershop != has_ordershop)
                {
                    Common.MessageBox.Show(this, "您进了另一家店，前一家的菜单已清空");
                    Common.Cookie.deleteCookie("dishcart");
                }
            }
        }
    }
}